<?php $this->load->view('header'); ?>
<?php $this->load->view('menus'); ?>

<br />
<h3><?=$this->project->title ?></h3>

	<ul class="shadetabs">
	<li><a href="<?=site_url('project/attach/comment/'.$this->project->project_id);?>">
		+ Comment</a></li>

	<? if( $this->Account->is_manager() || $this->Account->is_admin() ) { ?>
	<li><a href="<?=site_url('task/create/id/'.$this->project->project_id);?>">+ Task</a></li>
	<? } ?>

	<? if( $this->Account->is_admin() ) { ?>
	<li><a href="<?=site_url('project/attach/department/'.$this->project->project_id);?>">
		+ Departament</a></li>
	<li><a href="<?=site_url('project/remove/id/'.$this->project->project_id);?>" 
		onclick="return confirm('Are you sure?')">Delete</a></li>
	<? } ?>
	</ul>

	<div class="curlycontainer">
	<div class="innerdiv">
	<?=$this->project->description?>
	</div>
	</div>


<div id="project-tabs">
	<ul>
		<li><a href="#tasks-waiting"><span>Tasks waiting</span></a></li>
		<li><a href="#tasks-in-progress"><span>Tasks in progress</span></a></li>
		<li><a href="#finished-tasks"><span>Finished tasks</span></a></li>
		<li><a href="#comments"><span>Comments</span></a></li>
		<? if($this->Account->is_admin()) { ?>
			<li><a href="#attached-accounts"><span>Attached accounts</span></a></li>
		<? } ?>
	</ul>

	<div id="tasks-waiting">
		<? foreach( $this->Tasks->fetch_by_project_waiting($this->project->project_id) as $task ) {?>
			<big><a href="<?=site_url('task/view/id/'.$task->task_id)?>"><?=$task->title?></a>:</big>
			<i><?=$task->description?></i><br/ ><br />
		
			<? if($this->Account->is_manager() || $this->Account->is_admin()) { ?> 
			<a href="<?=site_url('task/remove/id/'.$task->task_id)?>"
				onclick="return confirm('Are you sure?')">delete</a>
			<? } ?>

			<hr />
		<? } ?>
	</div>

	<div id="tasks-in-progress">
		<? foreach( $this->Tasks->fetch_by_project_in_progress($this->project->project_id) as $task ) {?>
			<big><a href="<?=site_url('task/view/id/'.$task->task_id)?>"><?=$task->title?></a>:</big>
			<i><?=$task->description?></i>
	
			<? if($this->Account->is_manager() || $this->Account->is_admin()) { ?> 
			<a href="<?=site_url('task/remove/id/'.$task->task_id)?>"
				onclick="return confirm('Are you sure?')">delete</a>
			<? } ?>
	
			<hr />
		<? } ?>
	</div>

	<div id="finished-tasks">
		<? foreach( $this->Tasks->fetch_by_project_finished($this->project->project_id) as $task ) {?>
			<big><a href="<?=site_url('task/view/id/'.$task->task_id)?>"><?=$task->title?></a>:</big>
			<i><?=$task->description?></i>

			<? if($this->Account->is_manager() || $this->Account->is_admin()) { ?> 
			<a href="<?=site_url('task/remove/id/'.$task->task_id)?>"
				onclick="return confirm('Are you sure?')">delete</a>
			<? } ?>

			<hr />
		<? } ?>
	</div>

	<div id="comments">
		<? foreach( $this->ProjectComments->fetch_by_project($this->project->project_id) as $comment) {?>
			<?=$comment->text?><br />
			<? if($this->Account->is_admin() || $this->Account->is_manager()) { ?>
				<a href="<?=site_url('project/remove/comment/'.$comment->comment_id)?>"
					onclick="return confirm('Are you sure?')">delete</a>
			<? } ?>
			<hr />
		<? } ?>
	
		<form class="feedbackform" action="<?=site_url('project/attach/comment/'.$this->project->project_id);?>" method="post">

			<textarea name="comment" style="height: 50px"></textarea>

			<div class="buttonsdiv">
				<input type="submit" name="submit" value="Trimite" style="margin-left: 150px;" /> 
			</div>
		</form>

	</div>

	<? if($this->Account->is_admin()) { ?>
	<div id="attached-accounts">
		<? foreach( $this->Accounts->fetch_by_project($this->project->project_id) as $account ) { ?>
			<b>Department:</b><?=$this->Departments->fetch($account->department_id)->name?><br />
			<b>Utilizator:</b><?=$account->user ?><br />

			<? if($this->Account->is_admin() || $this->Account->is_manager()) { ?>
			<form action="<?=site_url('project/detach/account/'.$this->project->project_id);?>" method="post">
				<input type="hidden" name="account_id" value="<?=$account->account_id?>" />
				<button type="submit" name="submit">detach</button>
			</form>
			<? } ?>
			<hr />

		<? } ?>
	</div>
	<? } ?>
</div>

<script type="text/javascript">
	$('#project-tabs').tabs();
</script>


<?php $this->load->view('footer'); ?>
